package com.anders.springcloud.controller;

import com.anders.springcloud.pojo.Dept;
import com.anders.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class DeptController {
    @Autowired
    private DeptService deptService;

    // https://blog.csdn.net/lsqingfeng/article/details/105294828
    @PostMapping("/dept/add")
    public boolean addDept(@RequestBody Dept dept) {
        return deptService.addDept(dept);
    }

    @GetMapping("/dept/get/{id}")
    public Dept queryById(@PathVariable("id") long id) {
        return deptService.queryById(id);
    }

    @GetMapping("/dept/all")
    public List<Dept> queryAll() {
        return deptService.queryAll();
    }
}
